<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div id="result">
<div class="div_header1">Notes</div>
<br style="clear: both;" />
<table cellspacing="0" id="mytable" width="100%">
<tbody>
<?php
        $comments = $this->requestAction('/products/getnote/'.$pid.'/'.$sid.'/'.'1');
        //pr($comments);
        $nid=null;
        if(!empty ($comments)){
?>
       <tr>
            <td>
    <?php

        foreach($comments as $comment) {
        echo '<b>'.$comment['User']['username'].' [ '.date('d-m-Y g:i A',  strtotime($comment['Note']['created'])).' ] : </b> '.$comment['Note']['note'];echo"<br/>";
        //$j++;
          if(($pid==$comment['Note']['product_id'])&&($session->read('Auth.User.id')==$comment['Note']['user_id'])){
              $nid=$comment['Note']['id'];
               $note=$comment['Note']['note'];
          }
        }
?>
</td></tr>
        <?php

        }
        ?>
      </tbody>
</table>
    <form accept-charset="utf-8" action="<?php echo Configure::read('base_url');?>products/addnote_pending" method="post" id="productmessage">
<table cellspacing="0" class="tablesorter">
             <tbody>
                
                <tr>
                    <td >
                    <?php
                if($nid==null){
                echo $this->Form->hidden('Note.product_id',array('value'=>$pid));
		echo $this->Form->input('Note.note',array('cols'=>70,'class'=>'required'));
                }else{
                echo $this->Form->hidden('Note.id',array('value'=>$nid));
		echo $this->Form->input('Note.note',array('cols'=>70,'value'=>$note,'class'=>'required'));
                }
                ?>
                    </td>
                  </tr>
                 <tr>
                    <td >
                    <input type="submit" style="background:#73AE0B; color:#fff; font-size:14px;" name="button" id="button" value="add/update note" />
                    </td>
                  </tr>
                    </tbody>
                </table>
</form>
</div>
</body>
</html>
<?php  echo $html->script(array("jquery.min.js","jquery.form.js","jquery.validate.js", "jquery.tablesorter.min.js", "jquery.tablednd.js")); ?>
<script type="text/javascript">
 jQuery(document).ready(function(){


		var v = jQuery("#productmessage").validate({
                    rules: {
                    },
      submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#result"
				});
			}
		});


                 });


 </script>